/**
 * 
 */
package com.pi.reservaCita2.controler;

//import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.IsSerializable;
//import com.gwt.demo.client.mvc.Observer;

//import com.pi.reservaCita2.server.Observable;

/**
 * 
 * @author 
 * 
 */

public class Observable implements IsSerializable{
	private List observers;

	/**
	 * Add an Observer
	 * 
	 * @param asyncCallback
	 *            
	 * 
	 */
	public void addObserver(Observer observer) {
		if (observers == null) {
			observers = new ArrayList();
		}
		observers.add(observer);
	}

	/**
	 * Remove an Observer
	 * 
	 * @param observer
	 *            
	 */
	public void removeObserver(Observer observer) {
		if (observers != null) {
			observers.remove(observer);
		}
	}

	/**
	 * 
	 * 
	 */
	public void notifyObservers() {
		notifyObservers(null);
	}

	public void notifyObservers(Object hint) {
		if (observers != null) {
			Iterator iter = this.observers.iterator();
			while (iter.hasNext()) {
				Observer observer = (Observer) iter.next();
				observer.update(this, hint);
			}
		}
	}
	
	/*private static Observable instance;
	  public static synchronized Observable getInstance()
	  {
		   if(instance==null)
		   {
			instance=new Observable();   
		   }
		   return instance;
		  
	  }*/

}
